home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / diskBoot.OpenProm / local.mk < prev    next >
Encoding:
Text File  |  1991-01-14  |  9.4 KB  |  375 lines

  1. #
  2. # Makefile for boot programs in general.
  3. # This is included by Makefile.boot after $(TM).md/md.mk is included
  4. # The following variables should be defined already:
  5. #    NAME        program to be created
  6. #    OBJS        object files from which to create it
  7. #    CLEANOBJS    object files to be removed as part of "make clean"
  8. #            (need not just be object files)
  9. #    SRCS        sources for dependency generation
  10. #    TM        target machine type for object files, etc.
  11. #    TM        target machine type for object files etc.
  12. #    MACHINES    list of all target machines currently available
  13. #    INSTALLDIR    place to install program
  14. #    LINKSTART    address at which the boot program should be linked.
  15. #
  16. # Optional variables that may be defined by the invoker:
  17. #    XAFLAGS        additional flags to pass to assembler
  18. #    XCFLAGS        additional flags to pass to linker
  19. #    DEPFLAGS    additional flags to pass to makedepend
  20. #    no_targets    if defined, this file will not define all of the
  21. #            basic targets (make, make clean, etc.)
  22. #    use_version    if defined, then this file will set things up
  23. #            to include a version number that is automatically
  24. #            incremented
  25. #
  26. # $Header: /sprite/lib/pmake/RCS/boot.mk,v 1.16 90/11/02 10:41:30 jhh Exp $
  27. #
  28.  
  29. #
  30. # The variables below should be defined in md.mk, but they are given
  31. # default values just in case md.mk doesn't exist yet.
  32. #
  33. HDRS        ?=
  34. OBJS        ?=
  35. SRCS        ?=
  36.  
  37. #
  38. # First define search paths for libraries, include files, lint libraries,
  39. # and even sources.
  40. #
  41. .PATH.h        :
  42. .PATH.h        : $(TM).md /sprite/lib/include /sprite/lib/include/$(TM).md
  43. .PATH.h        : /sprite/lib/include/kernel /sprite/lib/include/kernel/$(TM).md
  44. .PATH.ln    : /sprite/lib/lint
  45. .PATH.c        :
  46. .PATH.c        : $(TM).md
  47. .PATH.s        :
  48. .PATH.s        : $(TM).md
  49.  
  50. #
  51. # Important directories. 
  52. #
  53. MISCLIBDIR    = /sprite/lib/misc
  54. BINDIR        = /sprite/cmds.$(MACHINE)
  55.  
  56. #
  57. # System programs -- assign conditionally so they may be redefined in
  58. # including makefile
  59. #
  60. AS        ?= $(BINDIR)/as
  61. CC        ?= $(BINDIR)/cc
  62. CHGRP        ?= $(BINDIR)/chgrp
  63. CHMOD        ?= $(BINDIR)/chmod
  64. CHOWN        ?= $(BINDIR)/chown
  65. CP        ?= $(BINDIR)/cp
  66. CPP        ?= $(BINDIR)/cpp -traditional -$
  67. CTAGS        ?= $(BINDIR)/ctags
  68. ECHO        ?= $(BINDIR)/echo
  69. LD        ?= $(BINDIR)/ld
  70. LINT        ?= $(BINDIR)/lint
  71. MAKEDEPEND    ?= $(BINDIR)/makedepend
  72. MKVERSION    ?= $(BINDIR)/mkversion
  73. MV        ?= $(BINDIR)/mv
  74. RM        ?= $(BINDIR)/rm
  75. SED        ?= $(BINDIR)/sed
  76. TEST            ?= $(BINDIR)/test
  77. TOUCH        ?= $(BINDIR)/touch
  78. UPDATE        ?= $(BINDIR)/update
  79.  
  80. #if !empty(TM:Msun4c)
  81. INSTALL_PROG    = update -s
  82. #endif
  83.  
  84. INSTALL_PROG    ?= /sprite/admin.$(MACHINE)/makeboot
  85. #
  86. # Several variables (such as where to install) are set based on the
  87. # TYPE variable.  Of course, any of these variables can be overridden
  88. # by explicit assignments.
  89. #
  90. TYPE        ?= boot
  91. INSTALLDIR    ?= /sprite/boot
  92. TMINSTALLDIR    ?= /sprite/boot/$(TM).md
  93.  
  94. #
  95. # Figure out what stuff we'll pass to sub-makes.
  96. #
  97. PASSVARS    = 'INSTALLDIR=$(INSTALLDIR)' 'TM=$(TM)' $(.MAKEFLAGS)
  98. #ifdef        XCFLAGS
  99. PASSVARS    += 'XCFLAGS=$(XCFLAGS)'
  100. #endif
  101. #ifdef        XAFLAGS
  102. PASSVARS    += 'XAFLAGS=$(XAFLAGS)'
  103. #endif
  104. #ifdef        NOBACKUP
  105. PASSVARS    += 'NOBACKUP=$(NOBACKUP)'
  106. #endif
  107. #ifdef        BACKUPAGE
  108. PASSVARS    += 'BACKUPAGE=$(BACKUPAGE)'
  109. #endif
  110.  
  111. #
  112. # Flags. These are ones that are needed by *all* boot programs. Any other
  113. # ones should be added with the += operator in the local.mk file.
  114. # The FLAGS variables are defined with the += operator in case this file
  115. # is included after the main makefile has already defined them...
  116.  
  117. #include     <tm.mk>
  118.  
  119. XCFLAGS        ?= -O
  120. CTFLAGS        ?= -wt
  121. XAFLAGS        ?=
  122. LINTFLAGS    ?= -m$(TM)
  123. INSTALLFLAGS    ?=
  124. LDFLAGS        += -L/sprite/lib/${TM}.md
  125. AFLAGS        += $(TMAFLAGS) $(XAFLAGS)
  126. CFLAGS        += $(TMCFLAGS) $(XCFLAGS) -I. -DKERNEL
  127. CFLAGS        += -DNO_PRINTF
  128.  
  129. #if !empty(TM:Mds3100)
  130. CFLAGS        += -I/sprite/lib/include -I/sprite/lib/include/$(TM).md
  131. AFLAGS        += $(.INCLUDES)
  132. #endif
  133.  
  134. CFLAGS        += -I../../kernel/Include/$(TM).md -I../../kernel/Include
  135.  
  136. # KERNELSTART is the absolute address at which the kernel expects to have
  137. # its code loaded.
  138. # LINKSTART is where the boot program is loaded into memory.  It has
  139. # to be loaded high enough so that the kernel image it loads does
  140. # not overwrite the boot program.  (If it does, it generally happens
  141. # as it zeros out the bss segment.  The PROM will abort with Exception 10
  142. # or something immediately after the boot program prints out the kernel sizes.)
  143. # BOOTDIR is the directory in which the boot things live.
  144. #
  145.  
  146. #if !empty(TM:Msun3)
  147. KERNELSTART    ?= 0x3fe0
  148. LINKSTART    ?= d4000
  149. #else
  150. #if !empty(TM:Msun4)
  151. KERNELSTART    ?= 0x4000
  152. LINKSTART    ?= $(KERNELSTART:S/0x/20/)
  153. #else
  154. #if !empty(TM:Mds3100)
  155. KERNELSTART    ?= 0x80010000
  156. LINKSTART    ?= $(KERNELSTART:S/0x//)
  157. #else
  158. #if !empty(TM:Msun4c)
  159. KERNELSTART    ?= 0x3fe0
  160. LINKSTART    ?= $(KERNELSTART:S/0x/20/)
  161. #else
  162. KERNELSTART    ?= 0x4000
  163. LINKSTART    ?= $(KERNELSTART:S/0x/b/)
  164. #endif
  165. #endif
  166. #endif
  167. #endif
  168.  
  169. CFLAGS        += -DBOOT_CODE=0x$(LINKSTART) \
  170.         -DKERNEL_START=$(KERNELSTART) -DBOOTDIR=\"$(INSTALLDIR)\" \
  171.         -DSAIO_COMPAT -DBOOT_FILE=\"$(TM)\"
  172.  
  173.  
  174. #
  175. # The .INCLUDES variable already includes directories that should be
  176. # used by cc and other programs by default.  Remove them, just so that
  177. # the output looks cleaner.
  178.  
  179. CFLAGS        += $(.INCLUDES:S|^-I/sprite/lib/include$||g:S|^-I/sprite/lib/include/$(TM).md$||g)
  180.  
  181. #
  182. # Transformation rules: these have special features to place .o files
  183. # in md subdirectories, run preprocessor over .s files, etc.
  184. # There are no profile rules for boot programs because they aren't profiled.
  185. #
  186.  
  187. .c.o        :
  188.     $(RM) -f $(.TARGET)
  189.     $(CC) $(CFLAGS) -c $(.IMPSRC) -o $(.TARGET)
  190. .s.o    :
  191. #if empty(TM:Mds3100)
  192.     $(CPP) $(CFLAGS:M-[ID]*) -m$(TM) -D$(TM) -D_ASM $(.IMPSRC) > $(.PREFIX).pp
  193.     $(AS) -o $(.TARGET) $(AFLAGS) $(.PREFIX).pp
  194.     $(RM) -f $(.PREFIX).pp
  195. #else
  196.     $(RM) -f $(.TARGET)
  197.     $(AS) $(AFLAGS) $(.IMPSRC) -o $(.TARGET)
  198. #endif
  199.  
  200. #
  201. # The following targets are .USE rules for creating things.
  202. #
  203.  
  204. #
  205. # MAKEBOOT usage:
  206. #    <program> : <objects> <libraries> MAKEBOOT
  207. #
  208. # Similar to MAKECMD, except it doesn't create the version.[ho] files,
  209. # and the variable LINKSTART is used to define where the boot program
  210. # gets loaded.
  211. #
  212. MAKEBOOT    :  .USE -lc
  213.     rm -f $(.TARGET)
  214.     $(LD) -N -e start -T $(LINKSTART) $(CFLAGS:M-L*) $(LDFLAGS) \
  215.         -o $(.TARGET) $(.ALLSRC:N-lc:Nend.o) -lc $(.ALLSRC:Mend.o)
  216.  
  217. #
  218. # MAKEINSTALL usage:
  219. #    install :: <dependencies> MAKEINSTALL
  220. #
  221. # The program is installed in $(TMINSTALLDIR) and backed-up to
  222. # $(TMINSTALLDIR).old
  223. #
  224. #ifndef NOBACKUP
  225. BACKUP        = -b $(TMINSTALLDIR).old
  226. #ifdef BACKUPAGE
  227. BACKUP += -B $(BACKUPAGE)
  228. #endif
  229. #else
  230. BACKUP        =
  231. #endif  NOBACKUP
  232.  
  233. MAKEINSTALL    : .USE
  234.     ${RM} -f $(TMINSTALLDIR)/$(NAME)
  235.     ${INSTALL_PROG} $(TM).md/$(NAME) $(TMINSTALLDIR)/$(NAME)
  236.  
  237. #
  238. # MAKELINT usage:
  239. #    <fluff-file> : <sources to be linted> MAKELINT
  240. #
  241. # <fluff-file> is the place to store the output from the lint.
  242. #
  243. MAKELINT    : .USE
  244.     $(RM) -f $(.TARGET)
  245.     $(LINT) $(LINTFLAGS) $(CFLAGS:M-[ID]*) $(.ALLSRC) > $(.TARGET) 2>&1
  246.  
  247. #
  248. # MAKEDEPEND usage:
  249. #    <dependency-file> : <sources> MAKEDEPEND
  250. #
  251. # Generate dependency file suitable for inclusion in future makes.
  252.  
  253. MAKEDEPEND    : .USE
  254.     @$(TOUCH) $(DEPFILE)
  255.     $(MAKEDEPEND) $(CFLAGS:M-[ID]*) -m $(TM) -w60 -f $(DEPFILE) $(.ALLSRC)
  256.     @$(MV) -f $(DEPFILE) $(DEPFILE).tmp
  257.     @$(SED) -e '/^#/!s|^.|$(TM).md/&|' <$(DEPFILE).tmp > $(DEPFILE)
  258.     @$(RM) -f $(DEPFILE).tmp
  259.  
  260. #if !defined(no_targets) && defined(NAME)
  261. #
  262. # We should define the main targets (make, make install, etc.).  See the
  263. # mkmf man page for details on what these do.
  264. #
  265. LIBS            ?=
  266.  
  267. #
  268. # start.o must come first
  269. default            : $(TM).md/$(NAME)
  270. $(TM).md/$(NAME)    : $(TM).md/start.o $(OBJS:S/$(TM).md\/start.o//:S/makeBoot.o//) MAKEBOOT
  271.  
  272.  
  273. clean            :: .NOEXPORT tidy 
  274.     $(RM) -f $(TM).md/$(NAME) 
  275.  
  276. tidy            :: .NOEXPORT 
  277.     $(RM) -f $(CLEANOBJS) $(CLEANOBJS:M*.o:S/.o$/.po/g) \
  278.             y.tab.c lex.yy.c core \
  279.         $(TM).md/lint \
  280.         a.out *~ $(TM).md/*~ version.h gmon.out mon.out
  281.  
  282. DEPFILE = $(TM).md/dependencies.mk
  283.  
  284. depend            : $(DEPFILE)
  285. $(DEPFILE)        ! $(SRCS:M*.c) $(SRCS:M*.s) MAKEDEPEND
  286.  
  287.  
  288. #
  289. # For "install", a couple of tricks.  First, allow local.mk to disable
  290. # by setting no_install.  Second, use :: instead of : so that local.mk
  291. # can augment install with additional stuff.  Third, don't install if
  292. # TMINSTALLDIR isn't set.
  293. #
  294. #ifndef no_install
  295. #ifdef TMINSTALLDIR
  296. install            :: $(TM).md/$(NAME) installman MAKEINSTALL
  297. #else
  298. install            :: .SILENT
  299.     echo "Can't install $(NAME):  no install directory defined"
  300. #endif TMINSTALLDIR
  301. #endif no_install
  302.  
  303.  
  304. #if empty(MANPAGES)
  305. installman        :: .SILENT
  306.     echo "There's no man page for $(NAME).  Please write one."
  307. #elif !empty(MANPAGES:MNONE)
  308. installman        ::
  309.  
  310. #elif defined(INSTALLMAN)
  311. installman        :: .SILENT
  312.     $(UPDATE) -m 444 -l $(INSTALLMANFLAGS) $(MANPAGES) $(INSTALLMAN)
  313. #else
  314. installman        :: .SILENT
  315.     echo "Can't install man page(s): no install directory defined"
  316. #endif
  317.  
  318.  
  319. lint            : $(TM).md/lint
  320. $(TM).md/lint        : $(SRCS:M*.c) $(HDRS) $(LIBS:M-l*) MAKELINT
  321.  
  322.  
  323. mkmf            :: .SILENT
  324.     mkmf
  325.  
  326.  
  327. newtm            :: .SILENT
  328.     if $(TEST) -d $(TM).md; then
  329.         true
  330.     else
  331.         mkdir $(TM).md;
  332.         chmod 775 $(TM).md;
  333.         mkmf -m$(TM)
  334.     fi
  335.  
  336. #
  337. # No profiling for boot programs
  338. #
  339. #profile            : $(TM).md/$(NAME)$(PROFSUFFIX)
  340. #$(TM).md/$(NAME)$(PROFSUFFIX)    : $(OBJS:S/.o$/.po/g) $(LIBS:S/.a$/_p.a/g)
  341. #    $(RM) -f $(.TARGET)
  342. #    $(CC) $(CFLAGS) -pg -o $(.TARGET) $(.ALLSRC)
  343.  
  344.  
  345. tags            :: $(SRCS:M*.c) $(HDRS)
  346.     $(CTAGS) $(CTFLAGS) $(SRCS:M*.c)
  347.  
  348. #
  349. # No version header for boot programs
  350. #
  351. #version.h        :
  352. #    $(RM) -f version.h
  353. #    $(MKVERSION) > version.h
  354.  
  355. DISTOBJS    ?=
  356.  
  357. dist:
  358. #if defined(DISTDIR) && !empty(DISTDIR)
  359.     for i in Makefile local.mk $(TM).md/md.mk $(SRCS) $(HDRS) $(DISTOBJS)
  360.     do
  361.     if $(TEST) -e $${i}; then
  362.         $(UPDATE)  $${i} $(DISTDIR)/$${i} ;else true; fi
  363.     done
  364. #else
  365.     @echo "Sorry, no distribution directory defined"
  366. #endif
  367.  
  368. #include    <all.mk>
  369.  
  370. #endif no_targets && NAME
  371.  
  372. .MAKEFLAGS    : -C        # No compatibility needed
  373.  
  374. #include    <rdist.mk>
  375.